package com.motus.pm.action;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;

import com.motus.pm.service.MeetingService;
import com.motus.pm.vo.MotusDept;
import com.motus.pm.vo.MotusEmpInfo;
import com.motus.pm.vo.PmMeetingInfo;
import com.motus.pm.vo.PmProjectInfo;
import com.motus.pm.vo.modelDriven.NewMeetingInfo;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller
public class CompanyAction extends ActionSupport implements
		ModelDriven<NewMeetingInfo> {

	private static final long serialVersionUID = 1L;

	@Autowired
	@Qualifier("newMeetingInfo")
	private NewMeetingInfo meeting;
	private List<PmMeetingInfo> meetingInfoList = new ArrayList<PmMeetingInfo>();
	private int deptid; // 用来获取部门信息
	private int type;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public List<PmMeetingInfo> getMeetingInfoList() {
		return meetingInfoList;
	}

	public void setMeetingInfoList(List<PmMeetingInfo> meetingInfoList) {
		this.meetingInfoList = meetingInfoList;
	}

	public int getDeptid() {
		return deptid;
	}

	public void setDeptid(int deptid) {
		this.deptid = deptid;
	}

	private List<MotusEmpInfo> empList = new ArrayList<MotusEmpInfo>();
	private List<MotusDept> deptList = new ArrayList<MotusDept>();

	public List<MotusDept> getDeptList() {
		return deptList;
	}

	public void setDeptList(List<MotusDept> deptList) {
		this.deptList = deptList;
	}

	public List<MotusEmpInfo> getEmpList() {
		return empList;
	}

	public void setEmpList(List<MotusEmpInfo> empList) {
		this.empList = empList;
	}

	@Autowired
	@Qualifier("meetingServiceImpl")
	private MeetingService meetingService;

	public MeetingService getMeetingService() {
		return meetingService;
	}

	public void setMeetingService(MeetingService meetingService) {
		this.meetingService = meetingService;
	}

	// public NewMeetingInfo getMeeting() {
	// return meeting;
	// }
	//
	// public void setMeeting(NewMeetingInfo meeting) {
	// this.meeting = meeting;
	// }
	// 会议列表
	public String showCMeetingList() {
		meetingInfoList = meetingService.meetingListByType(0);
		return SUCCESS;
	}

	// 新建会议
	public String newCMeeting() {
		// meetingService.newMeeting(meeting);
		return SUCCESS;
	}

	// 会议详情
	public String showCMeetingDetail() {
		return SUCCESS;
	}

	// 通过会议类型
	public String meetingInfoByType() {
		meetingInfoList = meetingService.meetingListByType(type);
		return SUCCESS;
	}

	// 创建会议
	public String createMeeting() {
		// 新建会议信息，并插入参会人员
		meetingService.newMeeting(meeting);
		meetingInfoList = meetingService.meetingListByType(0);
		return SUCCESS;
	}

	public String empInfo() {
		empList = meetingService.empList(deptid);
		return SUCCESS;
	}

	public String deptInfo() {
		deptList = meetingService.deptList();
		return SUCCESS;
	}

	@Override
	public NewMeetingInfo getModel() {
		// TODO Auto-generated method stub
		return meeting;
	}

	public String locateToDeptAction() {
		return "success";
	}

}
